﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EWDTAssignment
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            string code=Convert.ToString(Session["verifyCode"]);
            if (this.IsValid)
            {
                if (code == verificationTbx.Text)
                {
                    App_Code.Account temp = new App_Code.Account();
                    //Account(Username,Password,Question,Answer,Type,)
                    temp.Username = UsernameTbx.Text;
                    temp.Password = PasswordTbx.Text;
                    temp.Question = SecurityQuestionDL.Text;
                    temp.Answer = AnswerTbx.Text;
                    temp.Type = "customer";
                    int a =0;
                    a=App_Code.Account.createCustomerAccount1(temp);
                    if (a != 0)
                    {
                        Response.Redirect("Successfully.aspx");
                    }
                    
                }
                else
                {
                    verificationLabel.Text = "Invalid verify code";
                }
            }
            else
                return;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = UsernameTbx.Text;
            int a = App_Code.Account.checkAvailability1(username);
            if (a == 0)
            {
                AvailabilityLabel.Text = "Available!";
            }
            else
            {
                AvailabilityLabel.Text = "Not Available!";
            }
        }
    }
}